import { reactive } from "vue";
import axios from "axios";
// https://dog.ceo/api/breed/pembroke/images/random

export default function () {
    let dogList = reactive(["https://images.dog.ceo/breeds/pembroke/n02113023_3337.jpg"]);

    // function addDog(){
    //   axios.get("https://dog.ceo/api/breed/pembroke/images/random").then((res) => {
    //     dogList.push(res.data.message);
    //   });
    // }

    async function addDog() {
        try {
            let result = await axios.get("https://dog.ceo/api/breed/pembroke/images/random");
            dogList.push(result.data.message);
        } catch (err) {
            alert(err);
        }
    }
    // 向外部提供数据
    return {
        dogList,
        addDog
    }
}